/*     */ package com.jcraft.jzlib;
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ final class Tree
/*     */ {
/*     */   private static final int MAX_BITS = 15;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private static final int BL_CODES = 19;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private static final int D_CODES = 30;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private static final int LITERALS = 256;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private static final int LENGTH_CODES = 29;
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */   private static final int L_CODES = 286;
/*     */   
/*     */ 
/*     */ 
/*     */   private static final int HEAP_SIZE = 573;
/*     */   
/*     */ 
/*     */ 
/*     */   static final int MAX_BL_BITS = 7;
/*     */   
/*     */ 
/*     */ 
/*     */   static final int END_BLOCK = 256;
/*     */   
/*     */ 
/*     */ 
/*     */   static final int REP_3_6 = 16;
/*     */   
/*     */ 
/*     */ 
/*     */   static final int REPZ_3_10 = 17;
/*     */   
/*     */ 
/*     */ 
/*     */   static final int REPZ_11_138 = 18;
/*     */   
/*     */ 
/*     */ 
/*  62 */   static final int[] extra_lbits = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 
/*  63 */     2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5 };
/*     */   
/*     */ 
/*  66 */   static final int[] extra_dbits = { 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 
/*  67 */     5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 };
/*     */   
/*     */ 
/*  70 */   static final int[] extra_blbits = {
/*  71 */     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7 };
/*     */   
/*  73 */   static final byte[] bl_order = { 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 
/*  74 */     12, 3, 13, 2, 14, 1, 15 };
/*     */   
/*     */ 
/*     */ 
/*     */   static final int Buf_size = 16;
/*     */   
/*     */ 
/*     */ 
/*     */   static final int DIST_CODE_LEN = 512;
/*     */   
/*     */ 
/*  85 */   static final byte[] _dist_code = { 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 
/*  86 */     7, 7, 7, 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9, 10, 10, 
/*  87 */     10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 11, 11, 11, 
/*  88 */     11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 12, 12, 12, 12, 
/*  89 */     12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 
/*  90 */     12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, 13, 
/*  91 */     13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 
/*  92 */     13, 13, 13, 13, 13, 13, 13, 13, 13, 14, 14, 14, 14, 14, 14, 14, 14, 
/*  93 */     14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 
/*  94 */     14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 
/*  95 */     14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 
/*  96 */     14, 14, 14, 14, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
/*  97 */     15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
/*  98 */     15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
/*  99 */     15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 
/* 100 */     15, 0, 0, 16, 17, 18, 18, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 
/* 101 */     22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 24, 
/* 102 */     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 
/* 103 */     25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 
/* 104 */     26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 
/* 105 */     26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 
/* 106 */     27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 
/* 107 */     27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 28, 28, 28, 28, 28, 28, 28, 
/* 108 */     28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 
/* 109 */     28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 
/* 110 */     28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 28, 
/* 111 */     28, 28, 28, 28, 28, 28, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
/* 112 */     29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
/* 113 */     29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
/* 114 */     29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 29, 
/* 115 */     29, 29 };
/*     */   
/* 117 */   static final byte[] _length_code = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 8, 9, 9, 
/* 118 */     10, 10, 11, 11, 12, 12, 12, 12, 13, 13, 13, 13, 14, 14, 14, 14, 15, 
/* 119 */     15, 15, 15, 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 17, 17, 
/* 120 */     17, 17, 18, 18, 18, 18, 18, 18, 18, 18, 19, 19, 19, 19, 19, 19, 19, 
/* 121 */     19, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 
/* 122 */     21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 22, 
/* 123 */     22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 23, 23, 
/* 124 */     23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 24, 24, 24, 
/* 125 */     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 
/* 126 */     24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 25, 25, 25, 25, 25, 
/* 127 */     25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 
/* 128 */     25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 26, 26, 26, 26, 26, 26, 26, 
/* 129 */     26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 26, 
/* 130 */     26, 26, 26, 26, 26, 26, 26, 26, 27, 27, 27, 27, 27, 27, 27, 27, 27, 
/* 131 */     27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 27, 
/* 132 */     27, 27, 27, 27, 27, 28 };
/*     */   
/* 134 */   static final int[] base_length = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 10, 12, 14, 
/* 135 */     16, 20, 24, 28, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 
/* 136 */     224 };
/*     */   
/* 138 */   static final int[] base_dist = { 0, 1, 2, 3, 4, 6, 8, 12, 16, 24, 32, 48, 
/* 139 */     64, 96, 128, 192, 256, 384, 512, 768, 1024, 1536, 2048, 3072, 4096, 
/* 140 */     6144, 8192, 12288, 16384, 24576 };
/*     */   short[] dyn_tree;
/*     */   int max_code;
/*     */   StaticTree stat_desc;
/*     */   
/*     */   static int d_code(int dist) {
/* 146 */     return dist < 256 ? _dist_code[dist] : 
/* 147 */       _dist_code[(256 + (dist >>> 7))];
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   void gen_bitlen(Deflate s)
/*     */   {
/* 164 */     short[] tree = this.dyn_tree;
/* 165 */     short[] stree = this.stat_desc.static_tree;
/* 166 */     int[] extra = this.stat_desc.extra_bits;
/* 167 */     int base = this.stat_desc.extra_base;
/* 168 */     int max_length = this.stat_desc.max_length;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 174 */     int overflow = 0;
/*     */     
/* 176 */     for (int bits = 0; bits <= 15; bits++) {
/* 177 */       s.bl_count[bits] = 0;
/*     */     }
/*     */     
/*     */ 
/* 181 */     tree[(s.heap[s.heap_max] * 2 + 1)] = 0;
/*     */     
/* 183 */     for (int h = s.heap_max + 1; h < 573; h++) {
/* 184 */       int n = s.heap[h];
/* 185 */       bits = tree[(tree[(n * 2 + 1)] * 2 + 1)] + 1;
/* 186 */       if (bits > max_length) {
/* 187 */         bits = max_length;
/* 188 */         overflow++;
/*     */       }
/* 190 */       tree[(n * 2 + 1)] = ((short)bits);
/*     */       
/*     */ 
/* 193 */       if (n <= this.max_code)
/*     */       {
/*     */ 
/* 196 */         int tmp164_162 = bits; short[] tmp164_159 = s.bl_count;tmp164_159[tmp164_162] = ((short)(tmp164_159[tmp164_162] + 1));
/* 197 */         int xbits = 0;
/* 198 */         if (n >= base)
/* 199 */           xbits = extra[(n - base)];
/* 200 */         short f = tree[(n * 2)];
/* 201 */         s.opt_len += f * (bits + xbits);
/* 202 */         if (stree != null)
/* 203 */           s.static_len += f * (stree[(n * 2 + 1)] + xbits);
/*     */       } }
/* 205 */     if (overflow == 0) {
/*     */       return;
/*     */     }
/*     */     
/*     */     do
/*     */     {
/* 211 */       bits = max_length - 1;
/* 212 */       while (s.bl_count[bits] == 0)
/* 213 */         bits--;
/* 214 */       int tmp287_285 = bits; short[] tmp287_282 = s.bl_count;tmp287_282[tmp287_285] = ((short)(tmp287_282[tmp287_285] - 1)); int 
/* 215 */         tmp301_300 = (bits + 1); short[] tmp301_294 = s.bl_count;tmp301_294[tmp301_300] = ((short)(tmp301_294[tmp301_300] + 2)); int 
/* 216 */         tmp313_311 = max_length; short[] tmp313_308 = s.bl_count;tmp313_308[tmp313_311] = ((short)(tmp313_308[tmp313_311] - 1));
/*     */       
/*     */ 
/* 219 */       overflow -= 2;
/* 210 */     } while (
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 220 */       overflow > 0);
/*     */     
/* 222 */     for (bits = max_length; bits != 0; bits--) {
/* 223 */       int n = s.bl_count[bits];
/* 224 */       while (n != 0) {
/* 225 */         int m = s.heap[(--h)];
/* 226 */         if (m <= this.max_code)
/*     */         {
/* 228 */           if (tree[(m * 2 + 1)] != bits) {
/* 229 */             Deflate tmp384_383 = s;
/* 230 */             tmp384_383.opt_len = ((int)(tmp384_383.opt_len + (bits - tree[(m * 2 + 1)]) * tree[(m * 2)]));
/* 231 */             tree[(m * 2 + 1)] = ((short)bits);
/*     */           }
/* 233 */           n--;
/*     */         }
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   void build_tree(Deflate s)
/*     */   {
/* 245 */     short[] tree = this.dyn_tree;
/* 246 */     short[] stree = this.stat_desc.static_tree;
/* 247 */     int elems = this.stat_desc.elems;
/*     */     
/* 249 */     int max_code = -1;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 255 */     s.heap_len = 0;
/* 256 */     s.heap_max = 573;
/*     */     
/* 258 */     for (int n = 0; n < elems; n++) {
/* 259 */       if (tree[(n * 2)] != 0) {
/* 260 */         s.heap[(++s.heap_len)] = (max_code = n);
/* 261 */         s.depth[n] = 0;
/*     */       } else {
/* 263 */         tree[(n * 2 + 1)] = 0;
/*     */       }
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 271 */     while (s.heap_len < 2) {
/* 272 */       int node = s.heap[(++s.heap_len)] = max_code < 2 ? ++max_code : 0;
/* 273 */       tree[(node * 2)] = 1;
/* 274 */       s.depth[node] = 0;
/* 275 */       s.opt_len -= 1;
/* 276 */       if (stree != null) {
/* 277 */         s.static_len -= stree[(node * 2 + 1)];
/*     */       }
/*     */     }
/* 280 */     this.max_code = max_code;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 285 */     for (n = s.heap_len / 2; n >= 1; n--) {
/* 286 */       s.pqdownheap(tree, n);
/*     */     }
/*     */     
/*     */ 
/*     */ 
/* 291 */     int node = elems;
/*     */     do
/*     */     {
/* 294 */       n = s.heap[1];
/* 295 */       s.heap[1] = s.heap[(s.heap_len--)];
/* 296 */       s.pqdownheap(tree, 1);
/* 297 */       int m = s.heap[1];
/*     */       
/* 299 */       s.heap[(--s.heap_max)] = n;
/* 300 */       s.heap[(--s.heap_max)] = m;
/*     */       
/*     */ 
/* 303 */       tree[(node * 2)] = ((short)(tree[(n * 2)] + tree[(m * 2)]));
/* 304 */       s.depth[node] = ((byte)(Math.max(s.depth[n], s.depth[m]) + 1));
/* 305 */       tree[(n * 2 + 1)] = (tree[(m * 2 + 1)] = (short)node);
/*     */       
/*     */ 
/* 308 */       s.heap[1] = (node++);
/* 309 */       s.pqdownheap(tree, 1);
/* 292 */     } while (
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 310 */       s.heap_len >= 2);
/*     */     
/* 312 */     s.heap[(--s.heap_max)] = s.heap[1];
/*     */     
/*     */ 
/*     */ 
/*     */ 
/* 317 */     gen_bitlen(s);
/*     */     
/*     */ 
/* 320 */     gen_codes(tree, max_code, s.bl_count);
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   static void gen_codes(short[] tree, int max_code, short[] bl_count)
/*     */   {
/* 333 */     short[] next_code = new short[16];
/*     */     
/* 335 */     short code = 0;
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 341 */     for (int bits = 1; bits <= 15; bits++) {
/* 342 */       next_code[bits] = (code = (short)(code + bl_count[(bits - 1)] << 1));
/*     */     }
/*     */     
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/* 351 */     for (int n = 0; n <= max_code; n++) {
/* 352 */       int len = tree[(n * 2 + 1)];
/* 353 */       if (len != 0)
/*     */       {
/*     */ 
/* 356 */         int tmp75_73 = len; short[] tmp75_72 = next_code; short tmp77_76 = tmp75_72[tmp75_73];tmp75_72[tmp75_73] = ((short)(tmp77_76 + 1));tree[(n * 2)] = ((short)bi_reverse(tmp77_76, len));
/*     */       }
/*     */     }
/*     */   }
/*     */   
/*     */ 
/*     */ 
/*     */ 
/*     */ 
/*     */   static int bi_reverse(int code, int len)
/*     */   {
/* 367 */     int res = 0;
/*     */     do {
/* 369 */       res |= code & 0x1;
/* 370 */       code >>>= 1;
/* 371 */       res <<= 1;
/* 372 */       len--;
/* 368 */     } while (
/*     */     
/*     */ 
/*     */ 
/* 372 */       len > 0);
/* 373 */     return res >>> 1;
/*     */   }
/*     */ }


/* Location:              D:\Program Files\DBMS_20150813\jdbc\Dm7JdbcDriver17.jar!\com\jcraft\jzlib\Tree.class
 * Java compiler version: 2 (46.0)
 * JD-Core Version:       0.7.1
 */